/**
 * 量产线程并等待结束
 * 
 * 线程所做的工作是独立的，
 * std::men_fn
 */
#include <vector>
#include <thread>
#include <algorithm>
#include <functional>

void do_work(unsigned id)
{}

void f()
{
    std::vector<std::thread> threads;  //线程放入 vector 向线程自动化管理迈进一步
    for(unsigned i=0;i<20;++i)
    {
        threads.push_back(std::thread(do_work,i));
    }
    std::for_each(threads.begin(),threads.end(),
        std::mem_fn(&std::thread::join));
}

int main()
{
    f();
}
